define(function(require) {
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");

	var Model = function() {
		this.callParent();
	};

	Model.prototype.backBtnClick = function() {
		justep.Portal.closeWindow();
	};


//    //社区介绍
//	Model.prototype.introduceClick = function(event){
//		//justep.Shell.showPage({url : "$UI/communityOto/community/channel/introduce.w"});
//		this.getParentModel().goTo("$UI/communityOto/community/channel/introduce.w");
//	};
//	
//	//新闻
//	Model.prototype.news = function(event){
//	    
//		//justep.Shell.showPage({url : "$UI/communityOto/community/channel/newsList.w"});
//		this.getParentModel().goTo("$UI/communityOto/community/channel/newsList.w");
//	};
//	
//	Model.prototype.relation = function(event){
//		//justep.Shell.showPage({url : "$UI/communityOto/community/channel/contact.w"});
//		this.getParentModel().goTo("$UI/communityOto/community/channel/contact.w");
//	};
//	
//	
//	//社区服务
//	Model.prototype.serviceClick = function(event){
//		//justep.Shell.showPage({url : "$UI/communityOto/community/channel/lifeService.w"});
//		this.getParentModel().goTo("$UI/communityOto/community/channel/lifeService.w");
//	};
//	
//	//办事流程
//	Model.prototype.flowClick = function(event){
//		//justep.Shell.showPage({url : "$UI/communityOto/community/channel/flow.w"});
//		this.getParentModel().goTo("$UI/communityOto/community/channel/flow.w");
//	};
//	
//	
//	//政策法规
//	Model.prototype.regulationClick = function(event){
//			//justep.Shell.showPage({url : "$UI/communityOto/community/channel/regulation.w"});
//			this.getParentModel().goTo("$UI/communityOto/community/channel/regulation.w");
//	};
//	
//	
//	//工作动态
//	Model.prototype.trendsClick = function(event){
//		//justep.Shell.showPage({url : "$UI/communityOto/community/channel/workTrends.w"});
//		this.getParentModel().goTo("$UI/communityOto/community/channel/workTrends.w");
//	
//	};
//	
//	
	Model.prototype.onTouchStart = function(event){
		$(event.currentTarget).addClass("touch");
	};
	
	
	Model.prototype.onTouchEnd = function(event){
		$(event.currentTarget).removeClass("touch");
	};
//	
//	
//	//社区公告
//	Model.prototype.notifyClick = function(event){
//	    this.getParentModel().goTo("$UI/communityOto/community/channel/notify.w?type=notify");
//		//justep.Shell.showPage({url : "$UI/communityOto/community/channel/notify.w?type=community"});
//	};



	
	
	Model.prototype.areaDataCustomRefresh = function(event){
		var url = this.getParentModel().serverUrl + "/ex_community/a/api/community/officeMap?callback=?&id=3";
		
		var me = this;
		$.getJSON(url,function(data){
			if(data && data.data){
			    for(var i = 0;i<data.data.length;i++){
			    	data.data[i].mId = i+1;
			    }
				me.comp("areaData").loadData(data.data);
			}
		
		});

	};	
	
	Model.prototype.getTitleByRowId = function(id){
		var row = this.comp("areaData").getRowByID(id);
		if(row){
			return row.val('name');
		}
	};
	
	Model.prototype.getRowIDById = function(id){
		var row = this.comp("areaData").getRowByID(id);
		if(row){
			return row.val('id');
		}
	};
	
	
	Model.prototype.getAreaList = function(event){
	    
		justep.Shell.showPage("$UI/communityOto/community/streetList.w",{"areaId":$(event.currentTarget).attr('areaId')});

	};
	
	
	return Model;
});